﻿using Ldt.DataEngine.RuleAssemble;
using LdtDataEngin.ModuleDetail.BaseModule;
using LdtJudge.DataEngine.Common;
using LdtJudge.DataEngine.Common.XmlUtility;
using LdtJudge.DataEngine.DataBaseStores;
using LdtJudge.DataEngine.Model.DataModel.SystemtableModel;
using LdtJudge.DataEngine.Model.ElmentModel;
using LdtJudge.DataEngine.Model.XMLConfigModel.CircumsatanModel;
using LdtJudge.DataEngine.Model.XMLConfigModel.DataStores;
using LdtJudge.DataEngine.Model.XMLConfigModel.SituationPloModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LdtDataEngin.ModuleDetail.AnalysisModule.SituationPlot
{
    /// <summary>
    /// 违法行为获取
    /// </summary>
    public class AffordIllegalData : SituationPlotBaseClass
    {
        // <summary>
        /// 模块的配置
        /// </summary>
        private CircumsatanModel circumsatanModel = new CircumsatanModel();

        private XmlUtilCommon xmlUtilCommon;

        private SituationPlotMLConfigModel situationPlotML = new SituationPlotMLConfigModel();

        public AffordIllegalData(DataContext dataContext, string ConfigXml,string wfxwmach)
        {
            base.dataContext = dataContext;
            if (!string.IsNullOrEmpty(ConfigXml))
            {
                circumsatanModel = XmlUtility.DeserializeToObject<CircumsatanModel>(ConfigXml);
            }
            xmlUtilCommon = new XmlUtilCommon() { dataContext = dataContext };
            if (!string.IsNullOrEmpty(wfxwmach))
            {
                situationPlotML = XmlUtility.DeserializeToObject<SituationPlotMLConfigModel>(wfxwmach);
            }
           
        }

        /// <summary>
        /// 获取违法行为与违法情形信息
        /// </summary>
        /// <param name="dataModelList">需要添加的实体</param>
        /// <param name="parentID">父级ID</param>
        public void MatchAffordIllegal(List<DataModel> dataModelList, string parentID, string type)
        {
            bool isMatchLearn = false;
            SituationPlotMLCaseType mlCaseType = null;
            if (situationPlotML != null)
            {
                mlCaseType = situationPlotML.CaseTypes.FirstOrDefault(x => x.Value == dataContext.DataLayerAns.CaseType);
                if (mlCaseType != null)
                    isMatchLearn = true;
            }
            var dicValue = AffordExtPlotContent(dataModelList, parentID, type);
            if (dicValue.Count > 0)
            {
                foreach (var mode in dicValue)
                {
                    foreach (ForeignKey key in mode.Value)
                    {
                        string filpath = key.fileid;
                        if (!string.IsNullOrEmpty(filpath))
                        {
                            if (type == "3")
                            {
                                DataModel rootModel = XmlUtility.ConditionFirstOrDefaultDataModel(dataModelList, parentID, filpath);
                                if (rootModel != null)
                                {
                                    DataModel dataModelRoot = dataModelList.FirstOrDefault(a => a.ID == key.Fk);
                                    AttributeInfo attributeInfo = dataModelRoot.AttributesList.FirstOrDefault(a => a.Name == "领域ID");
                                    if (attributeInfo != null)
                                    {
                                        string causeID = attributeInfo.sourceList.FirstOrDefault(a => a.IsCheck == "1").SaveValue;

                                        #region 机器学习提取违法行为
                                        List<CommonPlotorSituation> commonPlotorList = new List<CommonPlotorSituation>();
                                        if (isMatchLearn && key.isml == "1")
                                        {
                                            key.isml = "1";
                                            if (!string.IsNullOrEmpty(mlCaseType.SplitCode))
                                            {
                                                List<string> valueList = RuleParseClass.GetParseRegCodeList(mlCaseType.SplitCode, new List<string> { key.Oringtext },"");
                                                commonPlotorList= MatchListByMachLearn(mlCaseType, causeID, valueList, 3);
                                            }
                                        }
                                        #endregion

                                        #region 正则提取违法行为
                                       
                                        CommElementRegexCode commElement = new CommElementRegexCode();
                                        commElement.CaseType = base.dataContext.DataLayerAns.CaseType;
                                        commElement.SourceCode = base.dataContext.DataLayerAns.SourceCode;
                                        commElement.PargarphCode = key.paragraphCode;
                                        commElement.PargarphWhere = "=";
                                        commElement.Purpose = ExtractType.weifaxingwei;
                                        var polt = MatchValueID(causeID, true, key.Oringtext, commElement, "0", dataContext.DataLayerAns.District, key.isml);
                                        commonPlotorList.AddRange(polt);
                                        foreach (CommonPlotorSituation commonPlotorSituation in commonPlotorList)
                                        {
                                            DataSave(commonPlotorSituation, key.Fk, dataModelList, parentID);
                                        }
                                        #endregion


                                    }

                                }

                            }
                            else if (type == "4")
                            {
                                List<DataModel> dataModelRootList = XmlUtility.ConditionDataModelList(dataModelList, parentID, filpath);
                                if (dataModelRootList.Count > 0)
                                {
                                    foreach (DataModel dataModelRoot in dataModelRootList)
                                    {
                                        AttributeInfo attributeInfo = dataModelRoot.AttributesList.FirstOrDefault(a => a.Name == key.nodename);
                                        if (attributeInfo != null)
                                        {
                                            string causeID = attributeInfo.sourceList.FirstOrDefault(a => a.IsCheck == "1").SaveValue;
                                            CommElementRegexCode commElement = new CommElementRegexCode();
                                            commElement.CaseType = base.dataContext.DataLayerAns.CaseType;
                                            commElement.SourceCode = base.dataContext.DataLayerAns.SourceCode;
                                            commElement.PargarphCode = key.paragraphCode;
                                            commElement.PargarphWhere = "=";
                                            commElement.Purpose = ExtractType.cailiangqingjie;
                                            SYS_CaseCause sYS_CaseCause = dALSYS_CaseCause.GetCauseModel(causeID);
                                            SYS_CaseCause sYS_CaseCauseAff = dALSYS_CaseCause.GetCauseModel(sYS_CaseCause.CC_ID, 35);
                                            var polt = MatchID(sYS_CaseCause.CC_ID, true, key.Oringtext, commElement, district: dataContext.DataLayerAns.District, parentId: sYS_CaseCauseAff?.CC_ID, type: "1");
                                            foreach (CommonPlotorSituation commonPlotorSituation in polt)
                                            {
                                                if (key.nodename == "违法行为ID")
                                                {
                                                    string name = "";
                                                    if (dataModelRoot.AttributesList.FirstOrDefault(a => a.Name == "违法行为名称") != null)
                                                    {
                                                        name = dataModelRoot.AttributesList.FirstOrDefault(a => a.Name == "违法行为名称").sourceList.FirstOrDefault(a => a.IsCheck == "1").SaveValue;
                                                    }
                                                    DataSaveAff(commonPlotorSituation, key.Fk, dataModelList, parentID, "1", causeID, name);
                                                }
                                                else
                                                {
                                                    DataSaveAff(commonPlotorSituation, key.Fk, dataModelList, parentID, "2", causeID);
                                                }

                                            }
                                        }
                                    }
                                }
                            }

                        }
                        else if (type == "4")
                        {

                            SYS_Casetype_CaseCauseRel sYS_Casetype_CaseCauseRel = dALSYS_CaseCause.Get_CaseCauseRel(dataContext.DataLayerAns.CaseType);
                            SYS_CaseCause sYS_CaseCauseRoot = dALSYS_CaseCause.GetCauseModel(sYS_Casetype_CaseCauseRel.CC_ID);
                            CommElementRegexCode commElement = new CommElementRegexCode();
                            commElement.CaseType = base.dataContext.DataLayerAns.CaseType;
                            commElement.SourceCode = base.dataContext.DataLayerAns.SourceCode;
                            commElement.PargarphCode = key.paragraphCode;
                            commElement.PargarphWhere = "=";
                            commElement.Purpose = ExtractType.cailiangqingjie;
                            SYS_CaseCause sYS_CaseCause = dALSYS_CaseCause.GetCauseModel(sYS_CaseCauseRoot.CC_ID);
                            SYS_CaseCause sYS_CaseCauseAff = dALSYS_CaseCause.GetCauseModel(sYS_CaseCause.CC_ID, 35);
                            var polt = MatchID(sYS_CaseCauseAff.CC_ID, true, key.Oringtext, commElement, district: dataContext.DataLayerAns.District);
                            foreach (CommonPlotorSituation commonPlotorSituation in polt)
                            {
                                DataSaveAff(commonPlotorSituation, key.Fk, dataModelList, parentID, "", "");
                            }
                        }
                    }
                }
                dataContext.DataLayerAns.AnalysisResultsDataModel.dataModelList = dataModelList;
                XmlDocument xmlDocumentp = XmlUtility.DataModelByXml(dataModelList);
                dataContext.DataLayerAns.AnalysisResultsXml = xmlDocumentp;
            }
        }


        public List<CommonPlotorSituation> MatchAffordValue(string duanLuoBH, string duanLuoNR, string causeID,string caseType,string sourceCode,string district,string isml)
        {

            List<CommonPlotorSituation> valueList = new List<CommonPlotorSituation>();
            Dictionary<string, List<ForeignKey>> dicValue = new Dictionary<string, List<ForeignKey>>();
            ForeignKey foreignKey = new ForeignKey();
            foreignKey.Oringtext = duanLuoNR;
            foreignKey.Fk = "";
            foreignKey.Path = "";
            foreignKey.paragraphCode = duanLuoBH;
            foreignKey.fileid = "";
            foreignKey.nodename = "";
            List<ForeignKey> foreignKeyList = new List<ForeignKey>();
            foreignKeyList.Add(foreignKey);
            dicValue.Add(causeID, foreignKeyList);

            foreach (var mode in dicValue)
            {
                foreach (ForeignKey key in mode.Value)
                {

                    CommElementRegexCode commElement = new CommElementRegexCode();
                    commElement.CaseType = caseType;
                    commElement.SourceCode = sourceCode;
                    commElement.PargarphCode = key.paragraphCode;
                    commElement.PargarphWhere = "=";
                    commElement.Purpose = ExtractType.weifaxingwei;
                    List<CommonPlotorSituation> poltList = MatchValueID(causeID, true, key.Oringtext, commElement,"0", district,key.isml);
                    valueList.AddRange(poltList);
                }
            }
            return valueList;
        }


        /// <summary>
        /// 添加匹配结果到结果集中
        /// </summary>
        /// <param name="commonPlotorSituation">匹配结果</param>
        /// <param name="nodeID">原文节点ID</param>
        /// <param name="dataModelAsisModelList">结果集</param>
        /// <param name="parentID">父级ID</param>
        public void DataSave(CommonPlotorSituation commonPlotorSituation, string nodeID, List<DataModel> dataModelAsisModelList, string parentID)
        {
            DataModel dataModelParent = dataModelAsisModelList.FirstOrDefault(a => a.ID == nodeID);
            if (dataModelParent != null)
            {
                DataModel dataModel = new DataModel();
                dataModel.XmlPath = dataModelParent.XmlPath + "/违法行为详情";
                dataModel.ParentId = dataModelParent.ID;
                dataModel.sourceData = new SourceData();
                dataModel.ID = Snowflake.Instance().GetId().ToString();
                Source source = new Source();
                source.SourceCode = dataContext.DataLayerAns.SourceCode;
                source.IsCheck = "1";
                dataModel.sourceData.sourceList = new List<Source>();
                dataModel.sourceData.sourceList.Add(source);
                DataSaveAtticeton(dataModel, commonPlotorSituation);
                dataModelAsisModelList.Add(dataModel);
                if (commonPlotorSituation.commonPlotorSituationList != null && commonPlotorSituation.commonPlotorSituationList.Count > 0)
                {
                    foreach (CommonPlotorSituation commonitem in commonPlotorSituation.commonPlotorSituationList)
                    {

                        DataModel dataModelqx = new DataModel();
                        dataModelqx.XmlPath = dataModel.XmlPath + "/违法行为情形";
                        dataModelqx.ParentId = dataModel.ID;
                        dataModelqx.sourceData = new SourceData();
                        dataModelqx.ID = Snowflake.Instance().GetId().ToString();
                        Source sourceqx = new Source();
                        sourceqx.SourceCode = dataContext.DataLayerAns.SourceCode;
                        sourceqx.IsCheck = "1";
                        dataModelqx.sourceData.sourceList = new List<Source>();
                        dataModelqx.sourceData.sourceList.Add(source);
                        DataSaveQXAtticeton(dataModelqx, commonitem);
                        dataModelAsisModelList.Add(dataModelqx);
                    }
                }
            }
        }


        public void DataSaveAff(CommonPlotorSituation commonPlotorSituation, string nodeID, List<DataModel> dataModelAsisModelList, string parentID, string type, string value, string valuetow = "")
        {
            DataModel dataModelParent = dataModelAsisModelList.FirstOrDefault(a => a.ID == nodeID);
            if (dataModelParent != null)
            {
                DataModel dataModel = new DataModel();
                dataModel.XmlPath = dataModelParent.XmlPath + "/详情";
                dataModel.ParentId = dataModelParent.ID;
                dataModel.sourceData = new SourceData();
                dataModel.ID = Snowflake.Instance().GetId().ToString();
                Source source = new Source();
                source.SourceCode = dataContext.DataLayerAns.SourceCode;
                source.IsCheck = "1";
                dataModel.sourceData.sourceList = new List<Source>();
                dataModel.sourceData.sourceList.Add(source);
                if (!string.IsNullOrEmpty(type))
                {
                    if (type == "1")
                    {
                        SetAttion("关联违法行为ID", value, dataModel);
                        SetAttion("关联违法行为名称", valuetow, dataModel);
                    }
                    else if (type == "2")
                    {
                        SetAttion("关联领域ID", value, dataModel);
                    }
                }
                dataModelAsisModelList.Add(dataModel);
                DataModel dataModelqx = new DataModel();
                dataModelqx.XmlPath = dataModel.XmlPath + "/裁量情节详情";
                dataModelqx.ParentId = dataModel.ID;
                dataModelqx.sourceData = new SourceData();
                dataModelqx.ID = Snowflake.Instance().GetId().ToString();
                Source sourceqx = new Source();
                sourceqx.SourceCode = dataContext.DataLayerAns.SourceCode;
                sourceqx.IsCheck = "1";
                dataModelqx.sourceData.sourceList = new List<Source>();
                dataModelqx.sourceData.sourceList.Add(source);
                DataSaveAtticetonAff(dataModelqx, commonPlotorSituation);

                DataModel dataModelor = new DataModel();
                dataModelor.XmlPath = dataModelqx.XmlPath + "/原文";
                dataModelor.ParentId = dataModelqx.ID;
                dataModel.sourceData = new SourceData();
                dataModelor.ID = Snowflake.Instance().GetId().ToString();
                Source sources = new Source();
                source.SourceCode = dataContext.DataLayerAns.SourceCode;
                source.IsCheck = "1";
                dataModelor.sourceData = new SourceData();
                dataModelor.sourceData.sourceList = new List<Source>();
                dataModelor.sourceData.sourceList.Add(sources);
                SetAttion("原文内容", commonPlotorSituation.Common_originalText, dataModelor);
                dataModelAsisModelList.Add(dataModelqx);
                dataModelAsisModelList.Add(dataModelor);

            }
        }


        public void DataSaveAtticetonAff(DataModel dataModel, CommonPlotorSituation commonPlotorSituation)
        {
            dataModel.AttributesList = new List<AttributeInfo>();
            SetAttion("情节ID", commonPlotorSituation.Common_id, dataModel);
            SetAttion("情节名称", commonPlotorSituation.Common_name, dataModel);
            SetAttion("裁量情节类型", commonPlotorSituation.Common_typeid, dataModel);



        }
        /// <summary>
        /// 保存数据--违法行为
        /// </summary>
        /// <param name="dataModel"></param>
        /// 
        public void DataSaveAtticeton(DataModel dataModel, CommonPlotorSituation commonPlotorSituation)
        {
            dataModel.AttributesList = new List<AttributeInfo>();
            SetAttion("违法行为ID", commonPlotorSituation.Common_id, dataModel);
            SetAttion("违法行为名称", commonPlotorSituation.Common_name, dataModel);
            SetAttion("原文", commonPlotorSituation.Common_originalText, dataModel);
        }

        /// <summary>
        /// 保存数据--违法情形
        /// </summary>
        /// <param name="dataModel"></param>
        public void DataSaveQXAtticeton(DataModel dataModel, CommonPlotorSituation commonPlotorSituation)
        {
            dataModel.AttributesList = new List<AttributeInfo>();
            SetAttion("违法行为情形ID", commonPlotorSituation.Common_id, dataModel);
            SetAttion("违法行为情形名称", commonPlotorSituation.Common_name, dataModel);
            SetAttion("原文", commonPlotorSituation.Common_originalText, dataModel);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="attributeName"></param>
        /// <param name="attributeValue"></param>
        /// <param name="dataModel"></param>
        public void SetAttion(string attributeName, string attributeValue, DataModel dataModel)
        {
            if (dataModel.AttributesList == null)
            {
                dataModel.AttributesList = new List<AttributeInfo>();
            }
            AttributeInfo attribute = new AttributeInfo();
            attribute.Name = attributeName;
            attribute.sourceList = new List<Source>();
            Source source = new Source();
            source.SaveValue = attributeValue;
            source.SourceCode = dataContext.DataLayerAns.SourceCode;
            source.IsCheck = "1";
            attribute.sourceList.Add(source);
            dataModel.AttributesList.Add(attribute);

        }
        /// <summary>
        /// TODO:ZSW district
        /// 进行违法行为与情形情节提取
        /// </summary>
        /// <param name="CauseID">父级案件ID</param>
        /// <param name="IsDevelopSchedule">匹配状态</param>
        /// <param name="MatchText">内容</param>
        /// <param name="commElement">条件对象</param>
        /// <param name="district">地域</param>
        /// <returns></returns>
        public override List<CommonPlotorSituation> MatchValueID(string CauseID, bool IsDevelopSchedule, string MatchText,CommElementRegexCode commElement, string affirmType, string district,string isml)
        {
            List<CommonPlotorSituation> listMPlot = new List<CommonPlotorSituation>();
            List<SYS_CaseCause> CommonTable = dALSYS_CaseCause.GetCaseCausesValueIDByAfford(CauseID,isml);
            if (CommonTable.Count > 0)
            {
                List<string> valueList = MatchListValueCommon(MatchText, CommonTable[0].CC_ID, commElement);
                if (valueList.Count > 0)
                {
                    MatchText = valueList[0];
                    if (string.IsNullOrWhiteSpace(district))
                    {
                        List<SYS_CaseCause> CommonTableC = dALSYS_CaseCause.GetCaseCausesValueAfford(CommonTable[0].CC_ID, 29);
                        base.LoopExtractPlotCommon(CauseID, MatchText, CommonTableC, CauseID, commElement, ref listMPlot);
                        foreach (var mPlot in listMPlot)
                        {
                            List<CommonPlotorSituation> listParentMPlot = new List<CommonPlotorSituation>();
                            List<SYS_CaseCause> CommonTableP = dALSYS_CaseCause.GetCaseCausesValueAfford(CommonTable[0].CC_ID, 32);
                            base.LoopExtractPlotCommon(CauseID, mPlot.Common_originalText, CommonTableP, mPlot.Common_id, commElement, ref listParentMPlot);
                            mPlot.commonPlotorSituationList = listParentMPlot;
                        }
                    }
                    else
                    {
                        List<SYS_CaseCause> CommonTableC = dALSYS_CaseCause.GetOffenceCauses(CommonTable[0].CC_ID, 29, district);
                        base.LoopExtractPlotCommon(CauseID, MatchText, CommonTableC, CommonTable[0].CC_ID, commElement, ref listMPlot);
                        foreach (var mPlot in listMPlot)
                        {
                            List<CommonPlotorSituation> listParentMPlot = new List<CommonPlotorSituation>();
                            List<SYS_CaseCause> CommonTableP = dALSYS_CaseCause.GetCaseCausesValueAfford(CommonTable[0].CC_ID, 32);
                            base.LoopExtractPlotCommon(CauseID, mPlot.Common_originalText, CommonTableP, mPlot.Common_id, commElement, ref listParentMPlot);
                            mPlot.commonPlotorSituationList = listParentMPlot;
                        }
                    }

                }
            }
            return listMPlot;
        }

        /// <summary>
        /// 裁量情节获取
        /// </summary>
        /// <param name="CauseID">违法行为Id</param>
        /// <param name="IsDevelopSchedule">匹配转台</param>
        /// <param name="MatchText">原文</param>
        /// <param name="commElement">条件对象</param>
        /// <param name="district">地域</param>
        /// <param name="parentId">父级ID</param>
        /// <param name="type"></param>
        /// <returns></returns>
        public List<CommonPlotorSituation> MatchID(string CauseID, bool IsDevelopSchedule, string MatchText, CommElementRegexCode commElement, string district, string parentId = "", string type = "")
        {
            List<CommonPlotorSituation> listMPlot = new List<CommonPlotorSituation>();
            SYS_CaseCause CommonTable = dALSYS_CaseCause.GetCauseModel(CauseID);
            if (CommonTable != null)
            {
                List<string> valueList = MatchListValueCommon(MatchText, CommonTable.CC_ID, commElement);
                if (valueList.Count > 0)
                {
                    foreach (string text in valueList)
                    {
                        List<SYS_CaseCause> CommonTableC = new List<SYS_CaseCause>();
                        if (string.IsNullOrEmpty(type))
                        {
                            CommonTableC = dALSYS_CaseCause.GetCaseCausesValueAfford(CauseID, 33, 34);
                        }
                        else
                        {
                            if (string.IsNullOrWhiteSpace(district))
                                CommonTableC = dALSYS_CaseCause.GetCaseCausesValueAfford(CauseID, 30);
                            else
                                CommonTableC = dALSYS_CaseCause.GetDiscretionaryPlotCauses(CauseID, parentId, 30, district);
                        }
                        base.LoopExtractPlotCommon(CommonTable.CC_ParentID, text, CommonTableC, CauseID, commElement, ref listMPlot);
                    }

                }
            }


            return listMPlot;
        }

        /// <summary>
        /// 获取情节配置
        /// </summary>
        /// <param name="tbl_id"></param>
        /// <param name="xmldoc"></param>
        /// <param name="dataModelAnalysisList"></param>
        /// <param name="parid"></param>
        /// <returns></returns>
        private Dictionary<string, List<ForeignKey>> AffordExtPlotContent(List<DataModel> dataModelAnalysisList, string parid, string type)
        {
            Dictionary<string, List<ForeignKey>> orgtext = new Dictionary<string, List<ForeignKey>>();
            if (circumsatanModel != null && circumsatanModel.casetypeModelList.Count > 0)
            {
                CasetypeModel casetypeModel = circumsatanModel.casetypeModelList.FirstOrDefault(a => a.Code.ToLower() == dataContext.DataLayerAns.CaseType.ToLower());
                if (casetypeModel != null)
                {
                    List<ParagraphModel> paragraphModelList = new List<ParagraphModel>();
                    paragraphModelList = casetypeModel.docTypeList.FirstOrDefault(a => a.Code.ToLower() == dataContext.DataLayerAns.SourceCode.ToLower()).paragraphModelList.Where(a => a.Type == type)?.ToList();
                    foreach (var casevalue in paragraphModelList)
                    {
                        foreach (var pathvlaue in casevalue.pathModelList)
                        {
                            foreach (DataModel dataModel in XmlUtility.ConditionDataModelList(dataModelAnalysisList, parid, pathvlaue.value))
                            {
                                ForeignKey key = new ForeignKey();
                                key.Oringtext = HttpHelp.DeCodeBase64new(65001, dataModel.sourceData.sourceList.FirstOrDefault(a => a.IsCheck == "1").OriginalText);
                                key.Fk = dataModel.ID;
                                key.Path = casevalue.pathModelList[0].value;
                                key.paragraphCode = casevalue.Code;
                                key.fileid = casevalue.field;
                                key.nodename = casevalue.nodename;
                                if (pathvlaue.paragraphModelList!=null && pathvlaue.paragraphModelList.Count>0)
                                {
                                    key.isml = pathvlaue.paragraphModelList[0].isml;
                                }
                                
                                if (orgtext.ContainsKey(casevalue.Type))
                                {
                                    orgtext[casevalue.Type].Add(key);
                                }
                                else
                                {
                                    List<ForeignKey> Keylist = new List<ForeignKey>();
                                    Keylist.Add(key);
                                    orgtext.Add(casevalue.Type, Keylist);
                                }
                            }

                        }
                    }
                }
            }


            return orgtext;
        }



    }
}
